package org.example.studyonline.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.example.studyonline.mapper.VideoWatchRecordMapper;
import org.example.studyonline.pojo.VideoWatchRecord;
import org.example.studyonline.service.VideoWatchRecordSerrvice;
import org.example.studyonline.utils.AuthUtils;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class VideoWatchRecordServiceImpl extends ServiceImpl<VideoWatchRecordMapper, VideoWatchRecord> implements VideoWatchRecordSerrvice {

    @Resource
    private VideoWatchRecordMapper videoWatchRecordMapper;
    @Override
    public void watch(Integer materialID) {
        VideoWatchRecord videoWatchRecord = new VideoWatchRecord();
        videoWatchRecord.setMaterialID(materialID);
        videoWatchRecord.setUserID(AuthUtils.getUserID());
        videoWatchRecord.setStartTime(LocalDateTime.now());
        videoWatchRecordMapper.insert(videoWatchRecord);
    }
}
